package com.csun.cmny.provider.service.impl;

import com.csun.cmny.base.dto.LoginAuthDto;
import com.csun.cmny.core.support.BaseService;
import com.csun.cmny.provider.dao.OmcChargeModelMapper;
import com.csun.cmny.provider.model.domain.OmcChargeModel;
import com.csun.cmny.provider.model.dto.OmcChargeModelDto;
import com.csun.cmny.provider.service.OmcChargeModelService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author chenzheng
 * @description:收费模块服务层
 * @date 2019/8/13 16:01
 */
@Slf4j
@Service
public class OmcChargeModelServiceImpl extends BaseService<OmcChargeModel> implements OmcChargeModelService {

    @Resource
    private OmcChargeModelMapper omcChargeModelMapper;

    @Override
    public int saveOmcChargeModel(OmcChargeModel omcChargeModel, LoginAuthDto loginAuthDto) {
        omcChargeModel.setUpdateInfo(loginAuthDto);
        if(omcChargeModel.isNew()){//保存
            return omcChargeModelMapper.insertSelective(omcChargeModel);
        }else{//更新
            return  omcChargeModelMapper.updateByPrimaryKeySelective(omcChargeModel);
        }
    }

    /**
     * 根据收费模块名模糊查询收费模信息
     * @param omcChargeModelDto
     * @return
     */
    @Override
    public List<OmcChargeModel> selectByName(OmcChargeModelDto omcChargeModelDto) {
        return omcChargeModelMapper.selectByName(omcChargeModelDto);
    }

}
